//根路径拼接
$.ajaxPrefilter(function (options) {
  options.url = "http://www.liulongbin.top:3007" + options.url;
  //设置headers
  //如果地址有/my，则需要携带token
  if (options.url.includes("/my")) {
    options.headers = {
      Authorization: localStorage.getItem("token")
    };
  }

  //判断是否有权限
  options.complete = function(xhr){
    const {status,message} = xhr.responseJSON
    if(status === 1 && message === '身份认证失败！') {
      //证明未登录，没有权限
      localStorage.removeItem('token')
      location.href = '/login.html'
    }
  }
});
